function get(key){
    let json = localStorage.getItem(key)
    if(json){
        try{
            json = JSON.parse(json)
        }catch {
            
        }
    }
    return json
}

function set(key, data){
    let json = data
    if(typeof data === 'object'){
        json = JSON.stringify(data)
    }
    localStorage.setItem(key, json)
}

export const ls = {
    get,
    set
}